$(function () {
    $(window).scroll(function () {
        if ($("html").scrollTop() < 675) {
            $(".PC_contents .customization  button>i").css("transform", "rotate(180deg)");
        } else {
            $(".PC_contents .customization  button>i").css("transform", "rotate(0deg)");
        }

    })


    $(".PC_contents .customization  button").click(function (e) {
        if ($(this).hasClass("open")) {
            $(this).removeClass("open");
            $(this).siblings(".address_button").css("display", "none");
        } else {
            if (this.getBoundingClientRect().y <= 300) {
                $(this).siblings(".address_button").css({
                    "display": "block",
                    "top": "50px"
                });
            } else {
                $(this).siblings(".address_button").css({
                    "display": "block",
                    "top": "-290px"
                });
            }
            $(this).addClass("open");
        }
        e.stopPropagation();
    })
    $("#fanhui").click(function (e) {
        if ($(".PC_contents .customization  button").hasClass("open")) {
            $(".PC_contents .customization  button").removeClass("open");
            $(".PC_contents .customization .address_button").css("display", "none");
            e.stopPropagation();
        }
    })
    $(".PC_contents .customization .address_button li").click(function () {
        $(this).parents(".address_button").css("display", "none").siblings("button").removeClass("open").children("span").html($(this).html());
    })

    $(".PC_contents .customization textarea").numtext(".PC_contents .customization .number_text span");

    // 移动端
    $(".visible-xs-block").click(function (e) {
        if($(".mobile_contents form button").hasClass("open")){
            $(".mobile_contents form button").removeClass("open");
            $(".mobile_contents form .mobile_address").css("display","none");
        }
    })

    $(".mobile_contents>.mobile_customization>form>div>button").click(function (e) {
        if ($(this).hasClass("open")) {
            $(this).removeClass("open");
            $(this).siblings(".mobile_address").css("display", "none");
        } else {
            $(this).siblings(".mobile_address").css("display", "block");
            $(this).addClass("open");
        }
        e.stopPropagation();
    })
})
$.fn.numtext = function (text) {
    $(this).keyup(function () {
        $(text).html(300 - $(this).val().length);
    })
}